<?php

//No direct access

defined('_JEXEC') or die('Restricted access');

?>
<div id="ownservices">
 <div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>
	<div id="mainownservice">
		<h3><?php echo JText::_('OWNSERVICE_USERS'); ?></h3>
		<hr />
		<?php if($this->access->canAdd): ?>
			<div id="toolbar">
				<a class="toolbar" onclick="javascript: submitbutton('add')" href="#">
					<span title="<?php echo JText::_('OWNSERVICE_NEW_USER'); ?>" class="icon-32-new"></span>
					<?php echo JText::_('OWNSERVICE_NEW_USER'); ?>
				</a>
			</div>
			<div class="clear"> </div>
		<?php endif; ?>
		<form action="<?php echo JRoute::_('index.php?option=com_ownservice'); ?>" method="post" name="adminForm">
			<table>
				<tr>
					<td width="100%">
						<?php echo JText::_( 'OWNSERVICE_FILTER' ); ?>:<input type="text" name="search" value="<?php echo htmlspecialchars($this->lists['search']);?>"  onchange="document.adminForm.submit();" />
						<button onclick="this.form.submit();" class="button">
							<?php echo JText::_( 'Go' ); ?>
						</button>
						<button onclick="document.adminForm.search.value='';this.form.submit();" class="button">
							<?php echo JText::_( 'Reset' ); ?>
						</button>
					</td>
					<td nowrap="nowrap">
						<?php 
							if(isset($this->lists['branch'])) {
								echo $this->lists['branch'];
							} 

							if(isset($this->lists['group'])) {
								echo $this->lists['group'];
							}

						?>

					</td>
				</tr>
			</table>
			<table class="adminlist" cellspacing="1">
				<tr>
					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_USERNAME', 'p.username', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>

					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_FIRSTNAME', 'p.firstname', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>

					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_LASTNAME', 'p.lastname', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>

					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_BIRTHDAY', 'p.birthday', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>
					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_PHONE', 'p.phone', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>
					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_DATE', 'p.created', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>
					<td align="center" class="tablelist">
						<?php echo JHTML::_('grid.sort',  'OWNSERVICE_GROUP', 'p.group_id', $this->lists['order_Dir'], $this->lists['order'] ); ?>
					</td>
					<td align="center" class="tablelist">
						<?php echo JText::_('OWNSERVICE_SELECT_ACTION'); ?>
					</td>
				</tr>
				<tfoot>
					<tr>
					  <td colspan="8"><?php echo $this->pageNav->getListFooter(true); ?></td>
					</tr>
				</tfoot>
				<tbody>
				<?php
					$k = 0;
					$dateformat  = OwnserviceHelper::getParams('date_format', '%d/%m/%Y'); 

					for($i=0,$n=count($this->rows);$i<$n;$i++): 

					$row = $this->rows[$i];

				?>
				<tr class="<?php echo "row$k"; ?>">
					<td class="inner_tablelist">
						<a href="index.php?option=com_ownservice&view=user&id=<?php echo $row->id; ?>">
							<?php echo $row->username; ?>
						</a>
					</td>
					<td class="inner_tablelist">
						<?php echo $row->firstname; ?>
					</td>
					<td class="inner_tablelist">
						<?php echo $row->lastname; ?>
					</td>
					<td class="inner_tablelist" align="center">
						<?php echo JHTML::_('date', $row->birthday, $dateformat); ?>
					</td>
					<td class="inner_tablelist" align="center">
						<?php echo $row->phone_no; ?>
					</td>
					<td class="inner_tablelist" align="center">
						<?php echo JHTML::_('date', $row->created, $dateformat); ?>
					</td>
					<td class="inner_tablelist" align="center">
						<?php echo $row->groupname; ?>
					</td>
					<td class="inner_tablelist" align="center">
						<select class="inputbox" name="action" id="action" onChange="listTaskAction(<?php echo $row->id ?>,this.value);">
							<option value="" selected>
								<?php echo JText::_('OWNSERVICE_PLEASE_SELECT'); ?>
							</option>
							<?php if($this->access->canView) : ?><option value="detail"><?php echo JText::_('OWNSERVICE_VIEW');?></option><?php endif; ?>
							<?php if($this->access->canEdit) : ?><option value="edit"><?php echo JText::_('OWNSERVICE_EDIT');?></option><?php endif; ?>
							<?php if($this->access->canDelete) : ?><option value="delete"><?php echo JText::_('OWNSERVICE_DELETE');?></option><?php endif; ?>
						</select>
					</td>
				</tr>
				<?php $k = 1 - $k; endfor; ?>
				</tbody>
			</table>
			<input type="hidden" name="id" value="" />
			<input type="hidden" name="option" value="com_ownservice" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid'); ?>" />
			<input type="hidden" name="controller" value="user" />
			<input type="hidden" name="view" value="users" />
			<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
			<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
			<?php echo JHTML::_( 'form.token' ); ?>
		</form>
	</div>
</div>